#include <stdio.h>
#include <stdlib.h>
#include "test.h"
#include "parent.h"
#include <bits/stdio2.h>
#include <sys/cdefs.h>

#define test23 3
#define SQR(x) ((x) * (x))
#define SUM(x) ((x) + (x))

extern const int j;
int main()
{
    printf("Hello World Zoulx !\n\n");

    printf("------------指针操作Start\n");
    const int intTestSize = 3;
    int intTest[test23] = {1, 2, 3};
    int *pIntTest;

    pIntTest = intTest;

    printf("实际数据\n");
    printf("pIntTest value[0] = %d ，value[1] = %d，value[2] = %d size = %ld \n", pIntTest[0], pIntTest[1], pIntTest[2], sizeof(intTest) / sizeof(int));

    printf("右移一位\n");
    *pIntTest++;
    printf("pIntTest value[0] = %d ，value[1] = %d，value[2] = %d size = %ld \n", pIntTest[0], pIntTest[1], pIntTest[2], sizeof(intTest) / sizeof(int));

    printf("交换位置\n");
    pIntTest[-1] = -3;
    pIntTest[0] = -2;
    pIntTest[1] = -1;

    // *(pIntTest - 1) = 3;
    // *pIntTest = 2;
    // *pIntTest++;
    // *pIntTest = 1;
    printf("intTest value[0] = %d ，value[1] = %d，value[2] = %d size = %ld \n", intTest[0], intTest[1], intTest[2], sizeof(intTest) / sizeof(int));

    printf("const修饰指针\n");
    const int *pTest2;
    // int *const pTest3;
    // const int *const p2;

    printf("------------指针操作End\n\n");

    printf("------------类继承操作Start\n");

    TestCls *cls = new TestCls();
    int result = cls->testFun(2, 3);

    delete cls;

    printf("------------类继承操作End\n\n");

    printf("------------类大小Start\n");
    TestStructA testValueStructA('C');
    TestStructB testValueStructB;
    VoidStruct testVoidStruct;

    printf("TestStructA size = %ld\n", sizeof(testValueStructA));
    printf("TestStructB size = %ld\n", sizeof(testValueStructB));
    printf("VoidStruct size = %ld\n", sizeof(testVoidStruct));

    printf("TestStructA size = %c\n", testValueStructA.cTest);

    printfl("------------类大小End\n");
#if (true)
    int a;
#endif

    div();
}

int add(int a, int b)
{
    return a + b;
}

void div()
{
    printf(" 2/(-2) = %d , 2%(-2) = %d\n", 2 / (-2), 2 % (-2));
}

TestCls::TestCls(/* args */)
{
    printf("TestCls(/* args */)\n");
}

TestCls::~TestCls()
{
    printf("~TestCls()\n");
}

int TestCls::testFun(int a, int b)
{
    int result = Parent::testFun(a, b);
    return result + 1;
}
